<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button class="btn">切换</button>
  <!-- hidden属性 -->
  <div id="box" class="cba" title="aaa" style="color: red">
    哈哈哈
  </div>
  <script>
    // 获取元素
    var boxEl = document.querySelector("#box")
    var btnEl = document.querySelector(".btn")
    btnEl.onclick = function () {
      console.log("按钮发生了点击", boxEl.hidden ? "显示" : "隐藏")
      boxEl.hidden = !boxEl.hidden
    }

  </script>
</body>

</html>